<?php

class User extends Model
{
	protected $table_name='users';
	
	public function has_unique_name()
	{
		$db=database();
		$result = $db->get_one("
			SELECT * FROM users 
			WHERE user_name = '" . $db->sanitize($this->user_name) . "'
			AND id != " . $db->sanitize($this->id));
		
		return (!$result);
	}
	
	public function get_events()
	{
		require_once('classes/managers/event_manager.php');
		$manager = new EventManager();
		$manager->user_id = $this->id;
		return $manager->get();
	}
}
?>